//     <one line to give the program's name and a brief idea of what it does.>
//     Copyright (C) 2021  Qiufeng54321
//
//     This program is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
//
//     You should have received a copy of the GNU General Public License
//     along with this program.  If not, see <https://www.gnu.org/licenses/>.

//
// Created by mac on 2021/6/2.
//

#ifndef PGETEMPLATE_MAPGROUP_H
#define PGETEMPLATE_MAPGROUP_H

#include "gen/Map_generated.h"
#include <fstream>
#include <string>

namespace williamcraft {
    class MapGroup {
        flatbuffers::FlatBufferBuilder builder{1024};
        std::fstream map_file;
        std::string path;
        std::unique_ptr<map::MapGroupT> map_group;

        static std::unique_ptr<map::MetadataT> create_metadata();

        static std::unique_ptr<map::DifficultyT> create_difficulty(std::string name);

    public:
        explicit MapGroup(std::string path);

        static MapGroup create_map(std::string path);

        std::unique_ptr<map::MapGroupT> get_map();

        void load();

        void save();
    };
}

#endif //PGETEMPLATE_MAPGROUP_H
